Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.Odbc
Public Class INF_USER
    Dim Conn As New OdbcConnection("Dsn=informix;uid=cas1win;pwd=cas1win")
    'Dim Conn As New OdbcConnection("Dsn=informix2")
    Dim DT As New DataTable
    Dim DS As New DataSet
    Dim CM As New OdbcCommand
    Dim DA As New OdbcDataAdapter
    Private Sub Result(ByVal SQL As String)
        DT.Clear()
        DS.Clear()
        DA.SelectCommand = New OdbcCommand(SQL, Conn)
        Try
            DA.Fill(DS)
            DT = DS.Tables(0)
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        End Try
    End Sub

    Public Function GetData(ByVal SQL As String)
        Result(SQL)
        Return Me.DT
    End Function

    Public Function GetData(ByVal EmployeeId As String, ByVal Columns As String, ByVal Rows As Integer)
        Dim SQL As String
        SQL = "SELECT * FROM per_divtab d, per_sectab s, per_deptab z, per_pertab p, per_postab t " & _
                "WHERE p.depcod[1,2]=d.divcod AND p.depcod[1,4]=s.seccod AND p.depcod=z.depcod AND p.posno=t.posno " & _
                "AND p.empid='" & EmployeeId & "' " & _
                "AND p.empstat='P'"

        'SQL = "select * from per_pertab,per_deptab,per_sectab,per_divtab,per_postab " & _
        '        "where(per_pertab.depcod = per_deptab.depcod) " & _
        '        "and  per_deptab.seccod=per_sectab.seccod " & _
        '        "and per_sectab.divcod=per_divtab.divcod " & _
        '        "and per_pertab.posno=per_postab.posno " & _
        '        "and empstat='P' " & _
        '        "and empid='" & EmployeeId & "'"

        Result(SQL)
        If DT.Rows.Count <> 0 Then
            If DS.Tables(0).Rows(Rows)(Columns).ToString <> Nothing Then
                Return DS.Tables(0).Rows(Rows)(Columns)
            End If
        Else
            Return Nothing
        End If
    End Function
End Class
